package com.ruoyi.bmxt.service.impl;

import java.util.List;

import com.ruoyi.bmxt.domain.web.SpecialtyDto;
import com.ruoyi.bmxt.domain.web.SpecialtySchoolDto;
import com.ruoyi.common.constant.BmxtConstants;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.bmxt.mapper.BmSpecialtyFeeMapper;
import com.ruoyi.bmxt.domain.BmSpecialtyFee;
import com.ruoyi.bmxt.service.IBmSpecialtyFeeService;

/**
 * 专业学费管理Service业务层处理
 * 
 * @author 魏建波
 * @date 2023-02-20
 */
@Service
public class BmSpecialtyFeeServiceImpl implements IBmSpecialtyFeeService 
{
    @Autowired
    private BmSpecialtyFeeMapper bmSpecialtyFeeMapper;

    /**
     * 查询专业学费管理
     * 
     * @param specialtyFeeId 专业学费管理主键
     * @return 专业学费管理
     */
    @Override
    public BmSpecialtyFee selectBmSpecialtyFeeBySpecialtyFeeId(Long specialtyFeeId)
    {
        return bmSpecialtyFeeMapper.selectBmSpecialtyFeeBySpecialtyFeeId(specialtyFeeId);
    }

    /**
     * 查询专业学费管理列表
     * 
     * @param bmSpecialtyFee 专业学费管理
     * @return 专业学费管理
     */
    @Override
    public List<BmSpecialtyFee> selectBmSpecialtyFeeList(BmSpecialtyFee bmSpecialtyFee)
    {
        return bmSpecialtyFeeMapper.selectBmSpecialtyFeeList(bmSpecialtyFee);
    }

    /**
     * 新增专业学费管理
     * 
     * @param bmSpecialtyFee 专业学费管理
     * @return 结果
     */
    @Override
    public int insertBmSpecialtyFee(BmSpecialtyFee bmSpecialtyFee)
    {
        bmSpecialtyFee.setCreateTime(DateUtils.getNowDate());
        return bmSpecialtyFeeMapper.insertBmSpecialtyFee(bmSpecialtyFee);
    }

    /**
     * 修改专业学费管理
     * 
     * @param bmSpecialtyFee 专业学费管理
     * @return 结果
     */
    @Override
    public int updateBmSpecialtyFee(BmSpecialtyFee bmSpecialtyFee)
    {
        bmSpecialtyFee.setUpdateTime(DateUtils.getNowDate());
        return bmSpecialtyFeeMapper.updateBmSpecialtyFee(bmSpecialtyFee);
    }

    /**
     * 批量删除专业学费管理
     * 
     * @param specialtyFeeIds 需要删除的专业学费管理主键
     * @return 结果
     */
    @Override
    public int deleteBmSpecialtyFeeBySpecialtyFeeIds(Long[] specialtyFeeIds)
    {
        return bmSpecialtyFeeMapper.deleteBmSpecialtyFeeBySpecialtyFeeIds(specialtyFeeIds);
    }

    /**
     * 删除专业学费管理信息
     * 
     * @param specialtyFeeId 专业学费管理主键
     * @return 结果
     */
    @Override
    public int deleteBmSpecialtyFeeBySpecialtyFeeId(Long specialtyFeeId)
    {
        return bmSpecialtyFeeMapper.deleteBmSpecialtyFeeBySpecialtyFeeId(specialtyFeeId);
    }

    @Override
    public String checkSchoolLevelSpecialtyNameUnique(BmSpecialtyFee bmSpecialtyFee) {
        Long specialtyFeeId = StringUtils.isNull(bmSpecialtyFee.getSpecialtyFeeId()) ? -1L : bmSpecialtyFee.getSpecialtyFeeId();
        BmSpecialtyFee dbSpecialtyFee = bmSpecialtyFeeMapper.checkSchoolLevelSpecialtyNameUnique(bmSpecialtyFee);
        if (StringUtils.isNotNull(dbSpecialtyFee) && dbSpecialtyFee.getSpecialtyFeeId().longValue() != specialtyFeeId.longValue())
        {
            return BmxtConstants.NOT_UNIQUE;
        }
        return BmxtConstants.UNIQUE;
    }

    @Override
    public List<SpecialtyDto> selectSchoolChildList(Long projectId) {
        return bmSpecialtyFeeMapper.selectSchoolChildList(projectId);
    }

    @Override
    public BmSpecialtyFee selectBmSpecialtyFeeByIdFromWeb(Long specialtyFeeId) {
        return bmSpecialtyFeeMapper.selectBmSpecialtyFeeByIdFromWeb(specialtyFeeId);
    }
}
